package com.diandian.backend.log.controller;

import com.diandian.backend.log.service.LogTaskService;
import com.diandian.backend.log.param.*;
import com.diandian.base.boot.starter.response.BaseResult;
import com.diandian.base.boot.starter.util.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * [日志]任务日志记录表
 */
@RestController
@RequestMapping("/log/task")
public class LogTaskController{

    @Autowired
    private LogTaskService logTaskService;

    /**
    * 分页查询
    */
    @PostMapping("/page")
    public BaseResult page(@RequestBody LogTaskPageParam param) {
        param.check();
        return ResultUtil.makeResult(logTaskService.page(param.toDTO()));
    }

    /**
     * 查询详情
     */
    @PostMapping("/detail")
    public BaseResult getDetail(@RequestBody LogTaskDetailParam param) {
        param.check();
        return ResultUtil.makeResult(logTaskService.getDetail(param.toDTO()));
    }

    /**
     * 修改数据(仅待执行的允许修改）
     */
    @PostMapping("/update/ready")
    public BaseResult updateReady(@RequestBody LogTaskUpdateReadyParam param) {
        logTaskService.updateReady(param.toDTO());
        return ResultUtil.makeResult();
    }

    /**
     * 修改操作状态
     */
    @PostMapping("/update/status")
    public BaseResult updateStatus(@RequestBody LogTaskUpdateStatusParam param) {
        param.check();
        logTaskService.updateStatus(param.toDTO());
        return ResultUtil.makeResult();
    }

    /**
     * 删除数据(仅待执行的允许修改）
     */
    @PostMapping("/delete/ready")
    public BaseResult deleteReady(@RequestBody LogTaskDeleteReadyParam param) {
        param.check();
        logTaskService.deleteReady(param.toDTO());
        return ResultUtil.makeResult();
    }

    /**
     * 新增
     */
    @PostMapping("/add")
    public BaseResult add(@RequestBody LogTaskAddParam param) {
        param.check();
        return ResultUtil.makeResult(logTaskService.add(param.toDTO()));
    }

    /**
     * 7. 列表查询
     */
//    @PostMapping("/list")
//    public BaseResult list(@RequestBody LogTaskListParam param) {
//        return ResultUtil.makeResult(logTaskService.getList(param.toDTO()));
//    }

}